//
//  18.二叉树的镜像.swift
//  数据结构与算法
//
//  Created by ZERO on 2021/5/19.
//

import Foundation
/*
 题目：操作给定的二叉树，将其变换为源二叉树的镜像。
 思路：递归做左右子树的交换
    
 */
func offer_18() {
    /*
     https://www.nowcoder.com/practice/a9d0ecbacef9410ca97463e4a5c83be7?tpId=13&tags=&title=&diffculty=0&judgeStatus=0&rp=1&tab=answerKey
     */
    print("测试用例查看剑指offer")
}

fileprivate class Solution {
    func mirror(_ pRoot: BinaryTreeNode<Int>?) -> BinaryTreeNode<Int>? {
        // write code here
        let temp = pRoot?.leftNode
        pRoot?.leftNode = pRoot?.rightNode
        pRoot?.rightNode = temp
        pRoot?.leftNode = mirror(pRoot?.leftNode)
        pRoot?.rightNode = mirror(pRoot?.rightNode)
        return pRoot
    }
}
